//
//  JKCellMyWelfare.m
//  chequanbao_ios
//
//  Created by 朱凯 on 2018/1/24.
//  Copyright © 2018年 com.itboye. All rights reserved.
//

#import "JKCellMyWelfare.h"

@implementation JKCellMyWelfare
{
    UIView      *_leftLine;
    UILabel     *_leftTitleLabel;
    UILabel     *_leftSubTitleLabel;
    UIView      *_sepLine;
    UILabel     *_rightTitleLabel;
    UILabel     *_descLabel;
    UIButton    *_enterButton;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
    
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    UIView *bgView = [UIView new];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.borderColor = [UIColor colorWithWhite:0.9 alpha:1].CGColor;
    bgView.layer.borderWidth = 1;
    [self.contentView addSubview:bgView];
    
    _leftLine = [UIView new];
    _leftLine.backgroundColor = rgba(118, 197, 250, 1);
    [bgView addSubview:_leftLine];
    
    
    _leftTitleLabel = [[UILabel alloc] init];
    _leftTitleLabel.text = @"600-3000元";
    _leftTitleLabel.font = B_FONT(16);
    _leftTitleLabel.textAlignment = NSTextAlignmentLeft;
    _leftTitleLabel.textColor = rgba(238, 120, 172, 1);
    [bgView addSubview:_leftTitleLabel];
    
    _leftSubTitleLabel = [[UILabel alloc] init];
    _leftSubTitleLabel.adjustsFontSizeToFitWidth = YES;
    _leftSubTitleLabel.text = @"截止日期：长期有效";
    _leftSubTitleLabel.font = B_FONT(14);
    _leftSubTitleLabel.textAlignment = NSTextAlignmentLeft;
    _leftSubTitleLabel.textColor = [UIColor lightGrayColor];
    [bgView addSubview:_leftSubTitleLabel];
    
    
    _sepLine = [UIView new];
    _sepLine.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
    [bgView addSubview:_sepLine];
    
    
    _rightTitleLabel = [[UILabel alloc] init];
    _rightTitleLabel.text = @"车险金大礼包";
    _rightTitleLabel.font = B_FONT(18);
    _rightTitleLabel.textAlignment = NSTextAlignmentLeft;
    _rightTitleLabel.textColor = [UIColor blackColor];
    [bgView addSubview:_rightTitleLabel];
    
    
    _descLabel = [[UILabel alloc] init];
    _descLabel.text = @"您将每年获得600-3000元车险大礼包甚至车险可免";
    _descLabel.numberOfLines = 2;
    _descLabel.font = B_FONT(14);
    _descLabel.textAlignment = NSTextAlignmentLeft;
    _descLabel.textColor = [UIColor lightGrayColor];
    [bgView addSubview:_descLabel];
    
    _enterButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _enterButton.userInteractionEnabled = false;
    [_enterButton setImage:[UIImage imageNamed:@"福利-进入"] forState:UIControlStateNormal];
    [_enterButton addTarget:self action:@selector(enter) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:_enterButton];
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(@10);
        make.right.equalTo(@-10);
        make.bottom.equalTo(@0);
    }];
    
    [_leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.top.equalTo(@0);
        make.width.equalTo(@10);
    }];
    
    [_sepLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@15);
        make.bottom.equalTo(@-15);
        make.width.equalTo(@1);
        make.left.equalTo(bgView.mas_centerX).multipliedBy(0.85);
    }];
    
    [_leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_leftLine.mas_right).offset(10);
        make.right.equalTo(_sepLine.mas_left).offset(-10);
        make.bottom.equalTo(bgView.mas_centerY).offset(-5);
    }];
    
    [_leftSubTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_leftTitleLabel);
        make.top.equalTo(bgView.mas_centerY).offset(0);
    }];
    
    [_enterButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@30);
        make.right.equalTo(bgView).offset(-5);
        make.centerY.equalTo(@0);
    }];
    
    [_rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_sepLine.mas_right).offset(10);
        make.right.equalTo(_enterButton.mas_left).offset(-5);
        make.bottom.equalTo(_leftTitleLabel);
    }];
    [_descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_rightTitleLabel);
        make.top.equalTo(_leftSubTitleLabel);
    }];
}

- (void)enter {
    
}
- (void)setIndex:(int)index {
    
    _index = index;
    if (index == 1) {
        _leftTitleLabel.text = @"赚钱红包";
        _rightTitleLabel.text = @"推荐亲朋好友，红包手不停";
        _descLabel.text = @"推荐亲朋好友消费均可源源不断的消费红包哦";
    }
}


@end
